package org.ysh.config;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import static org.ysh.core.cache.Constants.CURRENT_USER;

public class ReLoginForbiddenInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
        if (request.getSession().getAttribute(CURRENT_USER) != null) {
            response.sendRedirect("/");
            return false;
        }
        return true;
    }


}
